<template>
    <div>
        <el-table :data="tableData2.filter(data => !search || data.dicaName.toLowerCase().includes(search.toLowerCase()))" height="250" border style="width: 100%">
            <el-table-column prop="dicaCode" label="疾病分类编码" width="180">
            </el-table-column>
            <el-table-column prop="dicaName" label="疾病分类编码" width="180">
            </el-table-column>
            <el-table-column prop="sequenceNo" label="疾病分类编码">
            </el-table-column>
            <el-table-column align="left" >
                <template slot="header" slot-scope="scope">
                    <el-input v-model="search" size="mini" placeholder="输入关键字搜索" />
                </template>
                <template slot-scope="scope">
        <el-button
          size="mini"
          @click="goDisease(scope.$index, scope.row)" >选择</el-button>
      </template>
            </el-table-column>
        </el-table>



        <el-table :data="tableData.filter(data => !search1 || data.diseaseName.toLowerCase().includes(search1.toLowerCase()))" height="250" border style="width: 100%">
            <el-table-column prop="diseaseCode" label="疾病编码" width="180">
            </el-table-column>
            <el-table-column prop="diseaseICD" label="疾病编号" width="180">
            </el-table-column>
            <el-table-column prop="diseaseName" label="疾病名称">
            </el-table-column>
            <el-table-column align="left" >
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
import { getListFun, deleteByIdsFun, getListMoreFun } from '@/CommonJs/RequestApi';
export default {
    name: "Disease",
    data() {
        return {
            tableData: [],
            tableData2: [],
            search: '',
            selectListId: [],
            pageNum: 0,
            pageSize: 8,
            keywords: '',
            currentPage: 1,
            total: 0,
            diseCategoryID:0,
            search1:''
        }
    },
    components: {
      
    },methods:{
        goDisease(index,row){
            this.diseCategoryID=row.id
            getListFun('disease/get_disease', { page: this.currentPage, limit: this.pageSize, diseCategoryID: this.diseCategoryID }).then((response) => {
                console.log(response)
                this.tableData = response.data.data
                this.total = response.data.count
            })
        },
        handleCurrentChange(val) {
            this.currentPage = val;
            getListFun('disease/get_disease', { page: this.currentPage, limit: this.pageSize, diseCategoryID: this.diseCategoryID }).then((response) => {
                // console.log(response)
                this.tableData = response.data.data
                this.total = response.data.count
            })
        },
        deleteDepartments(row) {
            this.selectListId.push(row.id)
            deleteByIdsFun('delete_disease_more', this.selectListId).then(response => {
                location.reload();
            })
        },
        handleSelectionChange(val) {
            this.selectListId.push(val[val.length - 1].id);
            console.log(this.selectListId)
            //循环添加数组中最后一个的id给新数组
        },
        seach() {
            getListMoreFun('disease/get_dept_more', { page: this.currentPage, limit: this.pageSize, keywords: this.Seach.selectByDeptCode, keywords02: this.Seach.selectByDeptName, keywords03: this.Seach.selectByID }).then(response => {
                this.tableData = response.data.data
                this.total = response.data.count
            })
        },
        addDepartment() {
            this.$router.push('/AddDepartment');
        }
    }, mounted() {
        getListFun('diseCategory/get_diseCategory', { dicaName: '', dicaType: 1 }).then(response => {
            console.log(response)
            this.tableData2 = response.data.data
            this.total = response.data.count
        })
    }

}
</script>



<style scoped>
.tablebox {
    margin-top: 20px;
}
</style>